package net.wanho.controller;

import lombok.RequiredArgsConstructor;
import net.wanho.R.R;
import net.wanho.dto.LoginLogDTO;
import net.wanho.dto.OperaLogDTO;
import net.wanho.po.LoginLog;
import net.wanho.po.OperLog;
import net.wanho.service.LogService;
import net.wanho.vo.PageInfo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 这个类是：
 *
 * @author: MENG HU WANG
 * @date: 2025/2/7 16:34
 * @version: 1.0
 */
@RestController
@RequiredArgsConstructor
public class LogController {

    private final LogService logService;

    // 操作日志
    @GetMapping("oper-log")
    public R operaLog(@RequestParam(defaultValue = "1") int pageNum,
                      @RequestParam(defaultValue = "10") int pageSize,
                      OperaLogDTO operaLogDTO) {
        PageInfo<OperLog> pageInfo = logService.getOperaLogPageList(pageNum, pageSize, operaLogDTO);
        return R.ok(pageInfo);

    }


    // 登录日志
    @GetMapping("login-log")
    public R loginLog(@RequestParam(defaultValue = "1") int pageNum,
                      @RequestParam(defaultValue = "10") int pageSize,
                      LoginLogDTO loginLogDTO) {
        PageInfo<LoginLog> pageInfo = logService.getLoginLogPageList(pageNum, pageSize, loginLogDTO);
        return R.ok(pageInfo);
    }
}
